package com.example.zzm.yuejian03.Activity;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;

import com.example.zzm.yuejian03.Adapter.ClassAdapter;
import com.example.zzm.yuejian03.Fragment.BasesFragment;
import com.example.zzm.yuejian03.Listener.ClassListener;
import com.example.zzm.yuejian03.Model.ClassModel;
import com.example.zzm.yuejian03.R;

import com.example.zzm.yuejian03.Bean.ClassBean;

import org.w3c.dom.Text;

import java.util.List;

public class ClassActivity extends AppCompatActivity implements View.OnClickListener {

    private RecyclerView recyclerView;
    private TextView textView11;

  public void  onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_class);
      initViews();
      initEvent();
      int club_id = getIntent().getIntExtra("club_id",1);
      ClassModel classModel = new ClassModel();
      classModel.getClassList(club_id,listener);
//      ClassModel ClubModeldetails = new ClassModel();
//      ClubModeldetails.getClassList(getIntent().getIntExtra("club_id",1),listener);
  }

  ClassListener listener = new ClassListener() {
      @Override
      public void onResponse(List<ClassBean> beanlist) {
          ClassAdapter classAdapter = new ClassAdapter(getApplicationContext(),beanlist);
          recyclerView.setAdapter(classAdapter);
      }

      @Override
      public void onFail(String msg) {

      }
  };

    private void initEvent() {

        textView11.setOnClickListener(this);
    }

    private void initViews() {
        textView11 = (TextView)findViewById(R.id.textView11);
        recyclerView = (RecyclerView)findViewById(R.id.recyclerview);
        LinearLayoutManager layoutManager = new LinearLayoutManager(this.getApplicationContext());
        layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        recyclerView.setLayoutManager(layoutManager);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.textView11:
                finish();
                break;
        }
    }
}
